<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
		<title>替换switch方法</title>
		<style type="text/css">

		</style>
	</head>
	<body>
		替换switch方法
	</body>
	<script type="text/JavaScript">
	// 方法1：
	let playMap = new Map()
	playMap.set(1, '正常播放')
	playMap.set(2, '播放2分钟')
	playMap.set(3, '播放5分钟')
	playMap.set(5, '禁播')
	console.log(playMap.get(1))
	
	// 方法2：
	function getColor(type){
		let obj={
			"red":function(){
				return "red_"+type
			},
			"green":function(){
				return "green_"+type
			},
			"default":function(){
				return "default_"+type
			}
		}
		return (obj[type]||obj['default'])()
	}
	console.log( getColor('red'))
	</script>
</html>
